import dotenv
from langchain_community.tools import GoogleSerperRun
from langchain_community.utilities import GoogleSerperAPIWrapper
from langchain_core.pydantic_v1 import BaseModel, Field

from internal.lib import decorate

dotenv.load_dotenv()


class ArgsModel(BaseModel):
    query: str = Field(description="用户的问题")


@decorate("args_schema", ArgsModel)
def google_serper(**kwargs):
    return GoogleSerperRun(
        name="google_serper",
        description="可以根究用户的问题进行网络搜索",
        args_schema=ArgsModel,
        api_wrapper=GoogleSerperAPIWrapper()
    )
